home *** CD-ROM | disk | FTP | other *** search
- ;Script common.txt
- ;Last modified by JASON at 22/03/99 10:07:12
-
- ;Common.txt
- ;Global file which can be used by all parts of the program. Typically contains frequently used routines
-
- CreateMenuHotspots: declare intExcept
- ; the declare line allows parameters to be pased into the sub-routine
- ; in this instance we are passing i "intExcept" which will be used later in the routine
-
- ; we are creating a hotspot area for exiting the program
- ; the hotspot is called "menu_exit"
- ; it will call the subroutine "onExit_Click"
- ; the image "bexit" is defining the area to be used (with its offsets and width and height)
- ; the image "bexit" will be used as a push down image
- ; the image "bexitr" will be used as a rollover image
- Hotspot menu_exit gosub onExit_Click bexit bexitr
-
- ;- the mark/loop command is comparable to the FOR NEXT command as seen in basic
- ; i.e. below we are going to loop from 1 to 5
- ; the number of the loop is stored in the variable "@loop"
-
- mark 1 5
- ; --in GLPRO the if- else if - else - endif statement is the same as the BASIC statement
- ; we are checking to see if the value passed in is the same as the "@loop" variable
- If @intExcept==@Loop
- ; the HOTSPOT command defines an active region of the screen to be used
- ; as either a click point roll-over point mouse down inside etc
- ; check-out the command in the help file to understand its versatility
-
- ; we are creating a hotspots with a variable names "menu_button_1" ... "menu_button_5"
- ; using the @loop to append the variable name
- ; the subroutine to be called is "onMenu_Click" and we are passing it the current value of @loop
- ; the coordinates for the hot region are got from the image "mbut_01r" where again the @loop
- ; variable is used to create this name (the pad0 command is just used to format "1" to "01")
- ; this image contains offsets x and y and an x and y size
- ; the image will be displayed when the mouse is pressed over the area and the
- ; routine called when a click event is triggered (i.e mouse down and mouse up events within the region)
- Hotspot menu_button_$@loop gosub onMenu_Click:(@loop) mbut_$strPAD0(@loop,2)$r
- Else
- ; another hotspot command this time with a rollover image as well so when the mouse goes over
- ; the defines area an image is displayed
- ; for this purpose we are using the click down image for both the rollover and press down
- Hotspot menu_button_$@loop gosub onMenu_Click:(@loop) mbut_$strPAD0(@loop,2)$r mbut_$strPAD0(@loop,2)$r
- EndIf
- endloop
-
- RETURN
-
- onExit_Click:
- ; EXITNOW exits the GLPRO program
- ; if a shutdown text file exists it will run it
- ; by default the file is called "SHUTDOWN.TXT" but can be changed using "SET SHUTDOWN filename"
- ; the shutdown file in this project can be found in the shutdown directory1
- Exitnow
- Return
-
- onMenu_Click: declare intMenuButtonID
- ;A menu button has been clicked, if it is a different section than the current one then change
- If @gintCurrentSection<>@intMenuButtonID
- ;different section - clean up and go to new section
- ; calls FREEALL subroutine
- gosub FreeAll
- ; calls CreateMenuHotspots subroutine passing it the currently selected option
- gosub CreateMenuHotspots @intMenuButtonID
- ;fade up with fade number "3" the "menu_button_buffer" image we grabbed in the startup file
- imageFADEAT 3 menu_button_buffer
- ;fade the curently selected section button if "@intMenuButtonID" = 1 then it woulfd be
- ; mbut_01
- imageFADEAT 4 mbut_$strPAD0(@intMenuButtonID,2)
- ; set the value "gintCurrentSection" to the currently selected section
- Global gintCurrentSection @intMenuButtonID
- ; putup (no fade just display) the image "mainmdle"
- imagePUT mainmdle
- ; free this image
- imageFREE mainmdle
- ; this next section links to the file containing the code for the selected section i.e. IMAGES,ANIMATION(ANIM) etc
- if @intMenuButtonID==1
- ; because we are in a subroutine we need to free the stack before we link to another file
- ; POP ALL frees the stack (i.e. no depth)
- POP ALL
- ; LINK images.TXT will pass control to the file IMAGES.TXT all currently merged and active files are
- ; freed from memory
- ; to enter the images.txt file at a particular point you can specify a lable name i.e. LINK IMAGES.TXT mysub
- scriptLINK IMAGES.GLs
- else if @intMenuButtonID==2
- POP ALL
- scriptLINK ANIM.GLs
- else if @intMenuButtonID==3
- POP ALL
- scriptLINK SOUNDV.GLs
- else if @intMenuButtonID==4
- POP ALL
- scriptLINK HOTSPOT.GLs
- else if @intMenuButtonID==5
- POP ALL
- scriptLINK LAYERS.GLs
- endif
- endIf
- RETURN
-
- FreeAll:
- ;Free all possible whens, avi files, layers, clippings & images, hotspots, animations
- ;variables, and sounds - basically a clean up operation.
-
- ; - imageSET returns the drawing buffer to the on screen buffer as aposed to any buffers defined within the code
- imageSET
- ; - the drawREGION command by itself returns the drawing region of the screen to the full buffer
- drawREGION
- ; fontSHADOW 0 removes any previously defines font styles
- fontSHADOW 0
- ;- whenFREE is used to free when events - "whn*" will free all defines whens that start with "whn"
- whenFREE "whn*"
- ;---- this mci call closes all mci tasks currently being executed by GLPRO
- mci "close all"
- ;- layerFREE is used to free defined layers matching the given criteria "lyr*"
- layerFREE "lyr*"
- ; imageFREE is used to free clippings/images held in memory, For any free line the variables to be freed can be cascaded as below
- imageFREE "buf*" "snd*" "volup" "voldn" "playin" "forward" "rewind"
- imageFREE "roll" "down" "click" "star"
- ; hotFREE frees defines hotspots matching the given criteria "hot*"
- hotFREE "hot*"
- ; animFREE frees animations loaded in memory matching the given criteria "anim*"
- animFREE "anm*"
- ; varFREE is used to free variables
- varFREE "gintCurveX" "gintCurveY" "gintShipXoffset" "gintShipYoffset"
- varFREE "gintSoundName*" "gintSoundLoop*" "gintSoundVolume" "gintBalanceShare"
- ; soundFREE is used to free sound files
- soundFREE "snd*"
-
- ; the command "FREE"can also be used. FREE is not type specific so for example if you FREE "hot*"
- ; GLPRO will free all images, animations, variables, whens, hotspots, sound files etc that are defined
- ; meeting ther criteria "hot*"
-
- ; memory management is a very big part of GLPRO and optimising the speed of any presentation depend
- ; greatly on what is kept loaded in memory (i.e. will be used alot) and what is used and freed.
-
- ; The GLPRO engine itself occupies a lot less than 1MB of memory so there is a lot left there to play with
- ; most GLPRO applications occupy 1.2MB - 2.5MB of memory depending on how you optimise your code.
-
- Return
-